<?php
// Copyright 2012 @Wondershare
// $Id: main.php 437343 2012-08-04 07:16:28Z zhangqian $

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
$site = SITE_PATH.'protected/';
Yii::setPathOfAlias('site',$site);

//根据开发环境或者测试环境，对应不同的数据库配置
$db_config = array();

$db_config_development = array(
    'host'	=>    '10.10.16.109',
    'user'	=>    'root',
    'pass'	=>    '123456',
    'db'	=>    'ws_mobileportal'
);
$db_config_production = array(
    'host'	=>    '127.0.0.1',
    'user'	=>    'root',
    'pass'	=>    '123456',
    'db'	=>    'ws_mobileportal'
);
$db_config_testing = array(
    'host'	=>    '127.0.0.1',
    'user'	=>    'root',
    'pass'	=>    '123456',
    'db'	=>    'ws_mobileportal'
);

$configname = 'db_config_'.ENVIRONMENT;
//数据库配置
$db_config = $$configname;

return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'Mobile Portal',
    'viewPath'	=> APP_PATH.'views',   
	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
        'site.models.*',
        'site.components.*',
        'application.models.*',
		'application.components.*',
		'application.extensions.securimage.*',
        'application.extensions.*'
	),
	'modules'	=>    array(
	    'gii'=>array(
	    	'class'=>'system.gii.GiiModule',
	    	'password'=>'123456',
			// If removed, Gii defaults to localhost only. Edit carefully to taste.
			//'ipFilters'=>array('10.10.16.43','10.10.16.18','10.10.16.47','::1'),
		),
	),
    'timeZone'=>'GMT',
	'defaultController'=>'site',

	// application components
	'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
		),
		// uncomment the following to use a MySQL database
		'db'=>array(
			'connectionString' => "mysql:host={$db_config['host']};dbname={$db_config['db']}",
			'emulatePrepare' => true,
			'username' => "{$db_config['user']}",
			'password' => "{$db_config['pass']}",
			'charset' => 'utf8',
			'tablePrefix' => 'ap_',
		),
//		'cache' => array(
//            'class'     => 'system.caching.CMemCache',
//            'servers' => array(
//                array('host' => '192.168.116.130', 'port' => 12000, 'weight' => 60),
//             ),
//        ),
		'redis'	=>    array(
		    'class'	=>    'packages.redis.ARedisConnection',
		    'hostname'=>'localhost',
		    'port'	=>    '6379'
		),
		'session'=>array(
				'class' => 'system.web.CDbHttpSession',
				'timeout'=>'3600',
				'connectionID'=>'db',
				 'cookieParams'=>array(
				
				                        'path'  =>    '/',
				
				                        'domain'        =>    COOKIE_DOMAIN,
				
				                        'expires'       =>    0
				
				                    )

				
				),
		'errorHandler'=>array(
			// use 'site/error' action to display errors
            'errorAction'=>'site/error',
        ),
        'urlManager'=>array(
        	'urlFormat'=>'path',
        	'rules'=>array(
        		'users/connect/<provider:.*>'=>'users/connect',
        		'apps/<tag:.*?>'=>'apps/index',
        		'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        	),
        ),
		'log'=>array(  
            'class'=>'CLogRouter',  
            'routes'=>array(  
                array(  
                    'class'=>'CFileLogRoute',  
                    'levels'=>'error,warning',  
                ),  
                // 下面显示页面日志  
//                array(  
//                    'class'=>'CWebLogRoute',  
//                    'levels'=>'trace',     //级别为trace  
//                    'categories'=>'system.db.*' //只显示关于数据库信息,包括数据库连接,数据库执行语句  
//                ),
//                array(  
//                    'class'=>'CProfileLogRoute',  
//                    'levels'=>'trace',     //级别为trace  
//                    'categories'=>'system.db.*' //只显示关于数据库信息,包括数据库连接,数据库执行语句  
//                ),
            ),
        ),
	),
//    'cache'	=>    array(
//	    'class'=>'CRedisCache',
//	    'server'	=>    array(
//	    					'host'=>'127.0.0.1',
//	    					'port'=>6379,
//	                        )
//	),
	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>require(dirname(__FILE__).'/params.php'),
);